#ifndef	 _ANTS_H
#define	 _ANTS_H
	
#define MAX_HOSTNAME 255
#define LOWSPEED 3
#define MAX_THREAD 20
#define MIN_BUF_SIZE PACKSIZE
#define MAX_BUF_SIZE 32768
	
#define TIMES 30
#define PACKSIZE 1480
	
/* flag state for download*/
#define BREAKPOINT 1
#define NOBUFFER 2
#define FINISH 4
	
struct mission {
	int flag;
	int thread;
	int size;
	int count;
	int fd;	/*for save state*/
	int oneshot; /*for show time state*/
	struct ants *first_ant;
	unsigned short port;
	char *file_path;
	struct hostent *h;
	char user[30]; /*for ftp*/
	char pass[20]; /*for ftp*/
	char url[MAX_HOSTNAME];
	char host[MAX_HOSTNAME / 2];
	char path[MAX_HOSTNAME / 2];
	char file[MAX_HOSTNAME / 2];
	char referer[MAX_HOSTNAME / 2];
};
	
struct ants {
	int flag;
	struct mission *pms;
	int first;
	int thread;
	int buf_size;
	int s;
	int s_c; /*for ftp control socket*/
	int fd;
	int start;
	int end;
	int position;
	/*for packet data below*/
	int offset;
	int packsize;
	int bytesleft;
	char *data;
	char *buffer_start;
	char *buffer;
};
	
extern int statistic(struct ants *);
extern void fill_ants(struct ants *, struct mission *, int);
extern void state_save(struct mission *);
extern int scan_temp(char *);
extern int build_ants(struct mission *, char *, int *);
extern int rebuild_ants(int, struct mission *);
extern void download(struct mission *);
extern int del_file(char *);
	
	
#endif	
